#!/bin/bash

# Conversione dei csv forniti da Bcc in csv importabili da Homebank
echo "DATE;PAYMODE;INFO;PAYEE;MEMO;AMOUNT;CATEGORY;TAGS" > out_$1
awk 'BEGIN {ORS="";  FS=";" }
$1~/[0-9]/ {
  print $1 ";"; #date
  print    ";"; #paymode
  print    ";"; #info
  print    ";"; #payee
  print $4 ";"; #memo
  print $3 ";"; #amount
  print ";"     #category
  print ""      #tags
  print "\n"
}
END {
}
'  $1 |
grep -v Saldo |
sed -e's/  */ /g' |
iconv -f cp1251 -t utf-8 >> out_$1
